/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.goods.appweb;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.jeesite.common.responseReturn.entity.ResultObject;
import com.jeesite.common.responseReturn.utils.CommonUtils;
import com.jeesite.common.responseReturn.web.Render;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.goods.entity.ZtCustomer;
import com.jeesite.modules.goods.service.ZtCustomerService;
import com.jeesite.modules.recovery.entity.CustomerType;
import com.jeesite.modules.xcxAdmin.entity.ZtAdmin;

/**
 * 测试数据Controller
 * 
 * @author ThinkGem
 * @version 2018-04-22
 */
@Controller
@RequestMapping(value = "${frontPath}/ztCustomer")
public class AppZtCustomerController extends BaseController {

	@Autowired
	private ZtCustomerService ztCustomerService;

	/**
	 * 保存数据
	 */

	@PostMapping(value = "save")
	@ResponseBody
	public void save(HttpServletRequest request, HttpServletResponse response) {
		
		String paramStr=CommonUtils.getParams(request);
		
		JSONObject jo=JSONObject.parseObject(paramStr);
		String adminid = jo.getString("adminid");
		String type = jo.getString("type");
		String content = jo.getString("content");
		String imgs = jo.getString("imgs");
		String orderid = jo.getString("orderid");
		
		
		ResultObject res = new ResultObject();
		
		ZtCustomer ztCustomer=new ZtCustomer();
		
		ztCustomer.setCreateDate(new Date());
		ztCustomer.setContent(content);
		ztCustomer.setImgs(imgs);
		ztCustomer.setOrderid(orderid);
		ztCustomer.setType(type);
		
		ZtAdmin ztAdmin=new ZtAdmin();
		ztAdmin.setId(adminid);
		ztCustomer.setZtAdmin(ztAdmin);
		
		ztCustomerService.save(ztCustomer);
		
		res.setResult(200L);
		Render.renderString(response, res);
	}
	/**
	 * 查看物流信息
	 */
	@ResponseBody
	@RequestMapping(value = "getCustomerAllInfo")
	public void getCustomerAllInfo(HttpServletRequest request,
			HttpServletResponse response) {

		ResultObject res = new ResultObject();

		res.setResult(200L);
		res.setData(CustomerType.toList());
		Render.renderString(response, res);
	}

	
}